package progark.a9;

import progark.a9.screens.IntroScreen;
import sheep.game.Game;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

/**
 * @author firith
 * This is the Main Class for the Game
 * it inherits from the Android Activity class
 */
public class Progarka9Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        //Hide Application's title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
                
        //Creates a new game and save this game instance to the constants class
        Game game = new Game(this, null);
        Constants.MainGame = game;
        
        //Get server address from the string values
        Constants.server = getString(R.string.server_address);

        //Push the intro screen into the Game stack
        IntroScreen introScreen = new IntroScreen();
        game.pushState(introScreen);
        setContentView(game);
        
    }
       
    /* (non-Javadoc)
     * @see android.app.Activity#onKeyUp(int, android.view.KeyEvent)
     * If the Back or Home keys are pressed the application exits,
     * not just sleeps like a regular android application
     */
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
        	System.exit(0);
        }
        if (keyCode == KeyEvent.KEYCODE_HOME) {
            System.exit(0);
         }
        return true;
    }
}